<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>userController.as</title>
<link rel="stylesheet" type="text/css" href="../../SourceStyles.css"/>
</head>

<body><pre><span class="ActionScriptComment">// ActionScript file
</span><span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span>.<span class="ActionScriptDefault_Text">controls</span>.<span class="ActionScriptDefault_Text">Alert</span>;
<span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span>.<span class="ActionScriptDefault_Text">managers</span>.<span class="ActionScriptDefault_Text">CursorManager</span>;
<span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span>.<span class="ActionScriptDefault_Text">rpc</span>.<span class="ActionScriptDefault_Text">events</span>.<span class="ActionScriptDefault_Text">ResultEvent</span>;

<span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">userId</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>; <span class="ActionScriptComment">//用户ID号;
</span><span class="ActionScriptReserved">public</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">power</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptOperator">=</span>0;<span class="ActionScriptComment">//用户权限,0为普通用户,1为管理员
</span>        
<span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">loginValid</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptDefault_Text">user</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">passwd</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span>, <span class="ActionScriptDefault_Text">power</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span> 
<span class="ActionScriptBracket/Brace">{</span>
    <span class="ActionScriptDefault_Text">UserService</span>.<span class="ActionScriptDefault_Text">getOperation</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptString">&apos;validInfo&apos;</span><span class="ActionScriptBracket/Brace">)</span>.<span class="ActionScriptDefault_Text">send</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptDefault_Text">user</span>, <span class="ActionScriptDefault_Text">passwd</span>, <span class="ActionScriptDefault_Text">power</span> <span class="ActionScriptBracket/Brace">)</span>;
<span class="ActionScriptBracket/Brace">}</span>
        
<span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">loginValidHandler</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptDefault_Text">e</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">ResultEvent</span> <span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span>
<span class="ActionScriptBracket/Brace">{</span>
    <span class="ActionScriptDefault_Text">CursorManager</span>.<span class="ActionScriptDefault_Text">removeBusyCursor</span><span class="ActionScriptBracket/Brace">()</span>;
    <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">e</span>.<span class="ActionScriptDefault_Text">result</span> <span class="ActionScriptOperator">&amp;&amp;</span> <span class="ActionScriptDefault_Text">power</span><span class="ActionScriptOperator">==</span>1<span class="ActionScriptBracket/Brace">)</span>
    <span class="ActionScriptBracket/Brace">{</span>
        <span class="ActionScriptDefault_Text">userId</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">e</span>.<span class="ActionScriptDefault_Text">result</span>.<span class="ActionScriptDefault_Text">toString</span><span class="ActionScriptBracket/Brace">()</span>;
        <span class="ActionScriptDefault_Text">backToAdmin</span><span class="ActionScriptBracket/Brace">()</span>;
    <span class="ActionScriptBracket/Brace">}</span>
    <span class="ActionScriptReserved">else</span>
    <span class="ActionScriptBracket/Brace">{</span>
        <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptDefault_Text">e</span>.<span class="ActionScriptDefault_Text">result</span> <span class="ActionScriptBracket/Brace">)</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">userId</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">e</span>.<span class="ActionScriptDefault_Text">result</span>.<span class="ActionScriptDefault_Text">toString</span><span class="ActionScriptBracket/Brace">()</span>;
            <span class="ActionScriptDefault_Text">backToNavi</span><span class="ActionScriptBracket/Brace">()</span>;
        <span class="ActionScriptBracket/Brace">}</span>
        <span class="ActionScriptReserved">else</span>
        <span class="ActionScriptBracket/Brace">{</span>
            <span class="ActionScriptDefault_Text">Alert</span>.<span class="ActionScriptDefault_Text">show</span><span class="ActionScriptBracket/Brace">(</span> <span class="ActionScriptString">&apos;登录失败，请检查用户名、密码是否正确&apos;</span> <span class="ActionScriptBracket/Brace">)</span>;
        <span class="ActionScriptBracket/Brace">}</span>
    <span class="ActionScriptBracket/Brace">}</span>
<span class="ActionScriptBracket/Brace">}</span>
        
<span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">goReg</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span>
<span class="ActionScriptBracket/Brace">{</span>
    <span class="ActionScriptDefault_Text">currentState</span><span class="ActionScriptOperator">=</span><span class="ActionScriptString">&quot;reg&quot;</span>;
<span class="ActionScriptBracket/Brace">}</span></pre></body>
</html>
